"""
一个回合制游戏，每个角色都有hp 和power，hp代表血量，power代表攻击力，
hp的初始值为1000，power的初始值为200。
定义一个fight方法：
my_final_hp = my_hp - enemy_power
enemy_final_hp = enemy_hp - my_power
两个hp进行对比，血量剩余多的人获胜
"""
import random
def play_fun():
    my_hp = 1000
    my_power = 200
    enemy_hp = random.randint(500, 1200)
    enemy_power = random.randint(200, 300)

    # print(enemy_hp)
    # print(enemy_power)
    while True:
        my_hp = my_hp - enemy_power
        enemy_hp = enemy_hp - my_power

        # print(my_hp)
        # print("----------------")
        # print(enemy_hp)
        # print("\n")

        # 经过的打印数据，个人觉得判断两个值才比较准确输赢，可能都同时小于0
        if my_hp < 0 and enemy_hp > 0:
            print(f"我的剩余血量为{my_hp}")
            print(f"敌人的剩余血量为{enemy_hp}")
            print("我输了")
            break

        elif my_hp > 0 and enemy_hp < 0:
            print(f"我的剩余血量为{my_hp}")
            print(f"敌人的剩余血量为{enemy_hp}")
            print("我赢了")
            break

        elif my_hp < 0 and enemy_hp < 0:
            print(f"我的剩余血量为{my_hp}")
            print(f"敌人的剩余血量为{enemy_hp}")
            print("平局")
            break

if __name__ == "__main__":
    play_fun()
